package com.china.school;

import lombok.Data;
import org.springframework.format.annotation.NumberFormat;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.support.RequestContext;

import java.math.BigDecimal;

@Controller
public class TestController {

    @GetMapping("/")
    public String login(){
//        System.out.println(RequestContext.getTimeZone());
        return "loginForm";
    }

    @ResponseBody
    @PostMapping("/numberFormat")
    public Object numberFormat( @RequestBody  NumberFormatTest numberFormatTest    ){
        System.out.println(numberFormatTest);
         return numberFormatTest;
    }

    @Data
    public  static class NumberFormatTest{
//        @NumberFormat(pattern = "￥ ##,###.00")
        @NumberFormat(pattern = "￥ ")
        BigDecimal money;



        @NumberFormat(style = NumberFormat.Style.PERCENT)
        BigDecimal percent;
    }
}
